package com.xxxy.controller;

import com.xxxy.commonResult.CommonResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 处理登录或权限不足的异常请求
 */
@RestController
@RequestMapping("/error")
public class ErrorController {

    /**
     * 未登录异常
     *
     * @param error
     * @return
     */
    @ApiIgnore
    @GetMapping("/unAuthentication")
    public CommonResult<String> unAuthentication(String error) {
        return CommonResult.unauthorized(error);
    }

    /**
     * 权限不足异常
     *
     * @return
     */
    @ApiIgnore
    @GetMapping("/unAuthorization")
    public CommonResult<String> unAuthorization() {
        return CommonResult.forbidden("未授权");
    }
}
